home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
presto
/
presto10.lha
/
src
/
synchro.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-11
|
1KB
|
70 lines
#ifndef __presto__synchro_h__
#define __presto__synchro_h__
//
// Synchronization objects.
//
class SynchroObject : public Object {
Spinlock *so_lock;
ThreadQUnlocked *so_waiting;
public:
SynchroObject(int t, char *name=0);
~SynchroObject();
inline void remember(Thread* t);
inline Thread* recall();
inline void lock(); // always inline
inline void unlock(); // cyclic dependencies!
inline ThreadQUnlocked *waitingQueue();
virtual void print(ostream& = cout);
};
inline void
SynchroObject::lock()
{
register Spinlock *sp = so_lock;
sp->lock();
}
inline void
SynchroObject::unlock()
{
register Spinlock *sp = so_lock;
sp->unlock();
}
inline
Thread*
SynchroObject::recall()
{
register ThreadQUnlocked *soq = so_waiting;
return soq->get();
}
inline
void
SynchroObject::remember(Thread *t)
{
register ThreadQUnlocked *soq = so_waiting;
t->orstate(TS_BLOCKED);
//
// at this point, we are both blocked AND running. We have been
// blocked as far as the queue is concerned, but we still need
// to sleep ourselves before we can be considered not running
//
soq->append(t);
}
inline
ThreadQUnlocked*
SynchroObject::waitingQueue()
{
return so_waiting;
}
#endif /* __presto__synchro_h__ */